# coding=utf-8
import re
n=int(input())
for i in range(n):
    print(len(re.sub(r'[^0-9]', "", input())))